#ifndef KERNEL_UTILS_LINKEDLIST_H
#define KERNEL_UTILS_LINKEDLIST_H

#define LINKEDLIST_SIGNATURE ('LLST')
#define LINKEDLISTNODE_SIGNATURE ('LLND')

class CLinkedList;
class CLinkedListNode;

class CLinkedListNode
{
friend class CLinkedList;
public:
	CLinkedListNode();
	
	inline CLinkedListNode * GetPrev( void ) const { return fPrev; }
	inline CLinkedListNode * GetNext( void ) const { return fNext; }

private:
#if PARANOID
	uint32 fSignature;
#endif

	CLinkedListNode * fPrev;
	CLinkedListNode * fNext;
};


class CLinkedList
{
friend class CLinkedListNode;
public:
	CLinkedList();
	~CLinkedList();
	
	Result Add( CLinkedListNode * node );
	Result Insert( CLinkedListNode * node, CLinkedListNode * before );
	Result Remove( CLinkedListNode * node );
	
	CLinkedListNode * GetFirst( void ) { return fFirst; }
	CLinkedListNode * GetLast( void ) { return fLast; }
	uint32 GetCount( void ) { return fCount; }
	
private:
#if PARANOID
	uint32 fSignature;
#endif

	CLinkedListNode * fFirst;
	CLinkedListNode * fLast;
	uint32 fCount;
};


#endif // KERNEL_UTILS_LINKEDLIST_H
